package com.xiguanlezz.cn.api.remote.response;

import com.xiguanlezz.cn.api.remote.Payload;
import lombok.Getter;
import lombok.Setter;

/**
 * @Author：习惯了种种
 * @CreateDate：2024/11/19 11:13
 * @Description：响应父类
 */
// 为啥要实现Payload接口？只是为了方便将请求和响应类注册，这样就能使用类加载器加载Payload接口就可以扫描到所有请求响应对象
public abstract class Response implements Payload {
    @Setter
    @Getter
    private String message;
    @Setter
    @Getter
    // 和请求对象中的requestId一一对应
    private String requestId;
    @Setter
    @Getter
    private int resultCode = ResponseCode.SUCCESS.getCode();
    @Setter
    @Getter
    private int errorCode;
    private Throwable error;


    public boolean isSuccess() {
        return this.resultCode == ResponseCode.SUCCESS.getCode();
    }
}
